package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.dto.*;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.DeviceDataByDayVo;
import com.zzyl.nursing.vo.FamilyMemberElderVo;
import com.zzyl.nursing.vo.LoginVo;
import com.zzyl.nursing.vo.MyElderVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 * 
 * @author alexis
 * @date 2025-01-09
 */
@Api(tags = "老人家属管理")
@RestController
@RequestMapping("/member/user")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;

    @PostMapping("/login")
    public R<LoginVo> login(@RequestBody UserLoginRequestDto userLoginRequestDto) {
        // 调用Service层接口进行小程序登录
        LoginVo loginVo = familyMemberService.login(userLoginRequestDto);
        return R.ok(loginVo);
    }
    //家属绑定老人
    @PostMapping("/add")
    public AjaxResult bindingElder(@RequestBody BindingElderDto bindingElderDto){
        familyMemberService.bindingElder(bindingElderDto);
        return success();
    }
    //查询我的老人
    @GetMapping("/my")
    public AjaxResult MyElder(){
        List<MyElderVo> list = familyMemberService.MyElders();
        return success(list);
    }
    //分页查询已绑定的家人列表
    @GetMapping("/list-by-page")
    public AjaxResult listByPage(ElderDto dto){
       List<FamilyMemberElderVo> list= familyMemberService.listByPage(dto);
       return success(list);
    }
    //查询健康数据
    @PostMapping("/QueryDevicePropertyStatus")
    public AjaxResult deviceDataInfo(@RequestBody DeviceDto dto){
        return familyMemberService.deviceDataInfo(dto);
    }
    //按天统计指标数据
    @GetMapping("/queryDeviceDataListByDay")
    public AjaxResult queryDeviceDataListByDay(DeviceDataByDayDto dto){
      List<DeviceDataByDayVo> list= familyMemberService.queryDeviceDataListByDay(dto);
      return success(list);
    }
    @GetMapping("/queryDeviceDataListByWeek")
    public AjaxResult queryDeviceDataListByWeek(DeviceDataByDayDto dto){
      List<DeviceDataByDayVo> list= familyMemberService.queryDeviceDataListByWeek(dto);
      return success(list);
    }

}
